      subroutine refinagrid(X)

      use globais
      implicit none

      double precision, dimension(:,:), allocatable:: c0old !velocidade de propagacao, grid de incognitas
      double precision :: deltax0old, deltaz0old
      integer :: nx0old, nz0old, ndonoh
      integer :: i,j
      double precision :: X(n)

      call modelo2d(X,n)    ! cria o c0 referente ao X final
      allocate(c0old(nx0,nz0))
      c0old = c0
      nx0old = nx0
      nz0old = nz0
      deltax0old = deltax0
      deltaz0old = deltaz0

      deallocate(c0)

!       nx0 = (nx0-1)*2+nx0
!       nz0 = (nz0-1)*2+nz0
      nx0 = nx0+0
      nz0 = nz0+1
!       nx0 = 3 + int((kw-1)*(nx-3)/Nomega)
!       nz0 = 3 + int((kw-1)*(nz-3)/Nomega)



      deltax0 = Lx0/float(nx0-1)
      deltaz0 = Lz0/float(nz0-1)

      allocate(c0(nx0,nz0))


      call interpola(c0,nx0,nz0,c0old,nx0old,nz0old,1)

      deallocate(c0old)






      return
      end  subroutine refinagrid